package com.jiandan.plugin.task

import com.jiandan.plugin.PluginExtension
import com.jiandan.plugin.module.Firm
import com.jiandan.plugin.module.PgyerUpload
import com.jiandan.plugin.module.UmengUpload
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.TaskAction

class FirmTask extends DefaultTask {

    PluginExtension config

    FirmTask() {
        group = "firm360"
        description = "执行360加固"
        config = PluginExtension.getConfig(project)
    }

    @TaskAction
    def firmApkAndUpload() {
        println("firmApkAndUpload")
        new Firm(config).firmApkAndUpload()
        if (config.pgyerEnable) {
            new PgyerUpload().upload(config.apkFilePath, config.pgyerApikey)
        }
        if (config.umengEnable) {
            String mapping = config.getBuildDir() + config.getMappingPath()
            new UmengUpload().upload(mapping, config.umengApikey, config.umengSeckey, config.umengAppkey, config.apkVersionName)
        }
    }
}
